package org.weasel.business;

import java.util.ArrayList;

public class Iteration {

	private String id;
	private String name;
	private ArrayList<UserStory> userStories;
	private String notes;
	private String startDate;
	private String endDate;

	public Iteration(String id, String name, ArrayList<UserStory> userStories,
			String notes) {
		this.id = id;
		this.name = name;
		this.notes = notes;
		if (userStories != null)
			this.userStories = userStories;
		else
			this.userStories = new ArrayList<UserStory>();
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public ArrayList<UserStory> getUserStories() {
		return userStories;
	}

	public void setUserStories(ArrayList<UserStory> userStories) {
		this.userStories = userStories;
	}

	public UserStory getUserStory(String id) {
		for (UserStory us : userStories) {
			if (us.getId().equals(id))
				return us;
		}
		return null;
	}

	public void addUserStory(UserStory us) {
		userStories.add(us);
	}

	public void removeUserStory(String id) {
		UserStory us;
		for (int i = 0; i < userStories.size(); i++) {
			us = userStories.get(i);
			if (us.getId().equals(id)) {
				userStories.remove(i);
				return;
			}
		}
	}
}
